// ---------------------   左上task5 仪表盘图  --------------------------------------
function market7(market_name = '华冠超市') {
    $.post('http://127.0.0.1:5000/data-api/task7', {market_name: market_name}).done(function (data) {
        // 动态设置h2的标题
        document.getElementById('gauge').innerText = market_name + "占全部超市销量的比重";
        var myChart = echarts.init(document.querySelector(".rightMid .chart"));
        var option = {
            tooltip: {
                formatter: '{a} <br/>{b} : {c}%'
            },
            series: [{
                type: 'gauge',
                startAngle: 90,
                endAngle: -270,
                // max: 100000000, // 1亿
                max:data['total'],//所有超市的总额。
                radius: '100%',
                pointer: {
                    show: false
                },
                progress: {
                    show: true,
                    overlap: false,
                    roundCap: true,
                    clip: false,
                    itemStyle: {
                        borderWidth: 1,
                        borderColor: '#464646'
                    }
                },
                axisLine: {
                    lineStyle: {
                        width: 20
                    }
                },
                splitLine: {
                    show: false,
                    distance: 0,
                    length: 10
                },
                axisTick: {
                    show: false
                },
                axisLabel: {
                    show: false,
                    distance: 50
                },
                data: [
                    {
                        value: data['value'],
                        name: data['name'],
                        title: {
                            offsetCenter: ['0%', '-25%']
                        },
                        detail: {
                            offsetCenter: ['0%', '15%']
                        }
                    },
                ],
                title: {
                    fontSize: 25,
                    color: 'auto'

                },
                detail: {
                    fontSize: 20,
                    // color: '#b8edff',
                    color: 'auto',
                    formatter: function (value) {
                        var fmt = value + '\n' + (100*value/data['total']).toFixed(2) + '%';
                        return fmt
                    }
                }
            }]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
});
}

// 启动|刷新 浏览器调用
market7();
